from base.base_page import BasePage
from appium.webdriver.common.appiumby import AppiumBy


class LoginPage(BasePage):
    # 元素定位器
    USERNAME_INPUT = (AppiumBy.ID, "com.example:id/username")
    PASSWORD_INPUT = (AppiumBy.ID, "com.example:id/password")
    LOGIN_BUTTON = (AppiumBy.ID, "com.example:id/login_btn")

    def login(self, username, password):
        self.input_text(self.USERNAME_INPUT, username)
        self.input_text(self.PASSWORD_INPUT, password)
        self.click(self.LOGIN_BUTTON)
        return HomePage(self.driver)  # 假设跳转到主页